﻿@{
}
<section class="container-fluid m15_t">
    <div class="data-wrap case">
        <form class="form-inline" id="formSearch" onsubmit="return false;">
            <div class="data-tool clearfix">
                <div class="pull-left form-inline ">
                    <input class="hide" name="file" id="upfile" type="file" />
                    <a class="btn btn-default btn-sm m10_l" data-modal="/Bank/Add" data-title="新增银行" data-confirmname="确认" data-width="500" data-height="250"><span class="glyphicon glyphicon-plus"></span> 新增银行</a>
                </div>
                <div class="pull-right">
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">银行名称：</label>
                        <input class="form-control" name="BankName" type="text" autocomplete="off">
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">银行编码：</label>
                        <input class="form-control" name="BankCode" type="text" autocomplete="off">
                    </div>

                    <button type="button" class="btn btn-default btn-sm active gettext" id="btnSearch">搜索</button>
                </div>
            </div>
        </form>


        <div class="data-easyui data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table" id="pager"></table>
                </div>
            </div>
        </div>
    </div>
</section>
@section footerScript{

    <script type="text/javascript">

        var pageSize = 10;

        $(function () {
            FlashPay.UI.DataAutoHeight();

            doSearch();

            $("#btnSearch").click(function () {
                doSearch();
            });
        });


        function Tip_success(word) {
            FlashPay.UI.Tip_success(word);
        }

        function getParams() {
            var params = $("#formSearch").serializeJSON();
            return params;
        }

        function doSearch() {
            $("#pager").datagrid({
                fit: false,
                loadMsg: '数据加载中，请稍后……',
                method: "get",
                border: true,
                url: '/Bank/BankListQuery',
                queryParams: getParams(),
                pagination: true,
                pageSize: pageSize,
                pageList: [10, 15, 30, 50, 100, 1000],
                height: $(window).height() - 70,
                singleSelect: true,
                rownumbers: true,
                showFooter: true,
                idField: 'Id',
                onLoadSuccess: function () {
                    pageSize = $('#pager').datagrid('options').pageSize;
                },
                columns: [[
                    {
                        field: 'id',
                        title: "序号",
                        width: 75,
                        align: 'left',
                    },
                    {
                        field: 'bankCode',
                        title: '银行编码',
                        width: 100,
                        align: 'right'
                    },
                    {
                        field: 'bankName',
                        title: '银行名称',
                        width: 125,
                        align: 'right',
                    },
                    {
                        field: 'remark',
                        title: '备注',
                        width: 120,
                        align: 'left'
                    },
                    {
                        field: '_operate',
                        title: "操作",
                        width: 125,
                        align: 'center',
                        formatter: function (value, row, index) {
                            var buttonStr = '<a href="javascript:void(0)" data-modal="/bank/editBank?Id=' + row.id + '" data-title="编辑" data-width="500" data-height="250"><i class="glyphicon glyphicon-edit"></i>编辑</a>';
                            buttonStr += '&nbsp;&nbsp;<a href="#" onclick="doDel(' + row.id + ')"> <i class="glyphicon glyphicon-stop" style="color:red"></i>删除</a>';
                            return buttonStr;
                        }
                    },
                ]]
            });
        }


        function doDel(id) {
            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            art.dialog.confirm("确认删除此银行信息？", function () {
                FlashPay.Util.Ajax({
                    type: "POST",
                    url: "/bank/DelBank",
                    data: { Id:id },
                    success: function (res) {
                        if (res.success) {
                            cover.Remove();
                            FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                            FlashPay.UI.DialogOpener().doSearch();
                            FlashPay.UI.CloseDialog();
                        } else {
                            cover.Remove();
                            FlashPay.UI.Tip_short_warning("操作失败！" + res.message);
                        }
                    },
                    error: function (json) {
                        cover.Remove();
                        FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                    }
                });
            });
        }


    </script>
}


